Utility class providing an easier way to parse trees. More...
Public Member Functions | |
| TreeReader () noexcept | |
| TreeReader (const TreeReader &)=delete | |
| TreeReader (TreeReader &&other) noexcept | |
| void | addBool (bool &target, nkMemory::StringView path) |
| void | addInt (int &target, nkMemory::StringView path) |
| void | addUint (unsigned int &target, nkMemory::StringView path) |
| void | addFloat (float &target, nkMemory::StringView path) |
| void | addString (nkMemory::String &target, nkMemory::StringView path) |
| template<typename T > | |
| void | addVector (nkMemory::BufferCast< T > &target, std::function< T(nkExport::Node *)> entryFiller, nkMemory::StringView path) |
| template<typename T > | |
| void | addVector (std::vector< T > &target, std::function< T(nkExport::Node *)> entryFiller, nkMemory::StringView path) |
| template<typename T = std::string> | |
| void | addString (std::string &target, nkMemory::StringView path) |
| void | fill (nkExport::Node *tree) |
| TreeReader & | operator= (const TreeReader &)=delete |
| TreeReader & | operator= (TreeReader &&) noexcept |
Utility class providing an easier way to parse trees.
The typical use when directly working on a node can look like :
Using this utility, the code can be simplified to :
Note that like for a Node, the path can directly index objects and arrays.
|
noexcept |
Default constructor.
|
delete |
Copy constructor.
|
noexcept |
Move constructor.
| other | The other instance to move from. |
| void nkExport::TreeReader::addBool | ( | bool & | target, |
| nkMemory::StringView | path | ||
| ) |
Adds an boolean as a target.
| target | The target boolean to fill. |
| path | The member path in the tree. |
| void nkExport::TreeReader::addInt | ( | int & | target, |
| nkMemory::StringView | path | ||
| ) |
Adds an int as a target.
| target | The target int to fill. |
| path | The member path in the tree. |
| void nkExport::TreeReader::addUint | ( | unsigned int & | target, |
| nkMemory::StringView | path | ||
| ) |
Adds an unsigned int as a target.
| target | The target unsigned int to fill. |
| path | The member path in the tree. |
| void nkExport::TreeReader::addFloat | ( | float & | target, |
| nkMemory::StringView | path | ||
| ) |
Adds a float as a target.
| target | The target float to fill. |
| path | The member path in the tree. |
| void nkExport::TreeReader::addString | ( | nkMemory::String & | target, |
| nkMemory::StringView | path | ||
| ) |
Adds a string as a target.
| target | The target string to fill. |
| path | The member path in the tree. |
| void nkExport::TreeReader::addVector | ( | nkMemory::BufferCast< T > & | target, |
| std::function< T(nkExport::Node *)> | entryFiller, | ||
| nkMemory::StringView | path | ||
| ) |
Adds a vector as target. The provided buffer will be filled one entry at a time from given member path.
| target | The target buffer to fill. |
| entryFiller | The callback used to populate the entries which need to be filled. |
| path | The member path in the tree. |
| void nkExport::TreeReader::addVector | ( | std::vector< T > & | target, |
| std::function< T(nkExport::Node *)> | entryFiller, | ||
| nkMemory::StringView | path | ||
| ) |
Adds a vector as target, std template version. The provided vector will be filled one entry at a time from given member path.
| target | The target vector to fill. |
| entryFiller | The callback used to populate the entries which need to be filled. |
| path | The member path in the tree. |
| void nkExport::TreeReader::addString | ( | std::string & | target, |
| nkMemory::StringView | path | ||
| ) |
Adds a string as a target, std template version.
| target | The target string to fill. |
| path | The member path in the tree. |
| void nkExport::TreeReader::fill | ( | nkExport::Node * | tree | ) |
Fills the set targets using the provided tree.
| tree | The tree to fill the targets from. |
|
delete |
Copy assignment operator.
|
noexcept |
Move assignment operator.